package tgc.edu.demo.jkxt.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import tgc.edu.demo.jkxt.custom.BaseEntity;
import tgc.edu.demo.jkxt.entity.SysRole;

//总用户表
@Entity
@Table(name = "sysuser")
@Inheritance(strategy = InheritanceType.JOINED)
public class SysUser extends BaseEntity<Integer>{
	//用户名
	private String username;
	//密码
	private String password;
	//名字
	private String name;
	//身份证号
	private String IDCard;
	//身份
	private List<SysRole> roles=new ArrayList<SysRole>();
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getIDCard() {
		return IDCard;
	}
	public void setIDCard(String iDCard) {
		IDCard = iDCard;
	}
	public void setRoles(List<SysRole> roles) {
		this.roles = roles;
	}
	public SysUser() {
		super();
		// TODO Auto-generated constructor stub
	}

	public SysUser(Integer id) {
		super(id);
		// TODO Auto-generated constructor stub
	}
	
	@ManyToMany(cascade = CascadeType.REFRESH ,fetch = FetchType.EAGER)
	@JoinTable(name = "user_role",joinColumns = {@JoinColumn(name="user_id")},inverseJoinColumns = {@JoinColumn(name="role_id")})
	public List<SysRole> getRoles() {
		return roles;
	}
	
	
}
